package nju.software.tagmanager.common.context;

import nju.software.tagmanager.pojo.entity.User;

import java.util.List;

public class BaseContext {

    //--------------------当前用户id
    public static ThreadLocal<Integer> currentUserId = new ThreadLocal<>();
    public static void setCurrentUserId(Integer id) {
        currentUserId.set(id);
    }

    public static Integer getCurrentUserId() {
        return currentUserId.get();
    }

    public static void removeCurrentUserId() {
        currentUserId.remove();
    }

    //--------------------当前用户
    public static ThreadLocal<User> currentUser = new ThreadLocal<>();

    public static void setCurrentUser(User user) {
        currentUser.set(user);
    }

    public static User getCurrentUser() {
        return currentUser.get();
    }

    public static void removeCurrentUser() {
        currentUser.remove();
    }

    //---------------------当前用户角色
    public static ThreadLocal<List<String>> currentRoles = new ThreadLocal<>();

    public static void setCurrentRoles(List<String> roles) {
        currentRoles.set(roles);
    }

    public static List<String> getCurrentRoles() {
        return currentRoles.get();
    }

    public static void removeCurrentRoles() {
        currentRoles.remove();
    }

    //TODO -------------------当前用户角色 when roles contains 'special'
 }
